<?php

	/* dependence */
	CoreProject::Using('core.utils');

	/**
	 * @package		CoreProject
	 * @subpackage	Common
	 *
	 * cpr_Common_Packer
	 * 
	 */

	class cpr_Common_Packer
	{
		/**
		 *
		 * @param	array	$fileArray
		 * @param	string	$pathPrefix
		 * @param	string	$fileToSave
		 * @return	bool
		 */
		public function PackerInclude($fileArray, $pathPrefix, $fileToSave)
		{
			$return = true;
			if (file_exists($fileToSave))
			{
				include $fileToSave;
			}
			else
			{
/**/
				foreach ($fileArray as $fileForInclude)
				{
					include $pathPrefix.$fileForInclude;
				}
/*
				$phpText = '<?php ';
				foreach ($fileArray as $fileForInclude)
				{
					$phpText .= cpr_Core_Utils::ClearPhpFile(file_get_contents($pathPrefix.$fileForInclude)).' ';
				}

				if (@file_put_contents($fileToSave, $phpText))
				{
					include $fileToSave;
				}
				else
				{
					$return = false;
				}
/**/
			}
			
			return $return;
		}
	}
